package com.cat.greedyAlgorithm;

import java.io.*;

/**
 * @author 曲大人的喵
 * @description https://atcoder.jp/contests/abc427/tasks/abc427_b
 * @create 2025/10/11 20:08
 * @since JDK17
 */

public class Solution78 {
    static int N = ((int) (1e9 + 7)), n, m;


    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StreamTokenizer in = new StreamTokenizer(br);
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        // 接收输入
        in.nextToken();
        n = ((int) in.nval);
        int sum = 1;
        for (int i = 2; i <= n; i++) {
            int t = sum;
            while (t > 0) {
                sum += t % 10;
                t /= 10;
            }
        }
        out.println(sum);

        br.close();
        out.flush();
        out.close();
    }
}
